
    <?php
    $num =  count($field);
    if($num ==0){
    	$num =1;
    }
    ?>
    <link 	type="text/css"	rel="stylesheet"	href="/assets/css/default.css" />
    <p style="margin:20px">
	<form id="form1" name="form1" class="easyui-form" method="post" data-options="novalidate:true" action ="">
		 <input   name="id"  type="hidden"  value="<?php echo $id  ?>">
		 <input  id="myid"   type="hidden"  value="<?php echo $num ?>">
		 <a href="javascript:void(0)" class="easyui-linkbutton c9" style="width:10%" onclick="myadd()">add</a>
		<table id="mytable" cellpadding="5" border="2">
			<tr >
			<td colspan="2">人员信息</td>
			<td colspan="5">  <input name ="is_person" type="radio" value="1" <?php if($is_person ==1) echo "checked" ?>>是<input name ="is_person" type="radio" value="0" <?php if($is_person ==0) echo "checked" ?>>否</td>

         	</tr>
         	<tr >
			<td colspan="2">是否单选</td>
			<td colspan="5"> <input name ="single_select" type="radio" value="1" <?php if($single_select ==1) echo "checked" ?>>是<input name ="single_select" type="radio" value="0" <?php if($single_select ==0) echo "checked" ?>>否</td>

         	</tr>
		<?php  if(empty($field)) { ?>
    		<tr id="tr1">
			<td>采集字段名1</td>
				<td align="left" width="200">
					 <input class="easyui-textbox "  name="name[]"   type="text"    value="" >
             	</td>
             <td>字段显示名称1</td>
				<td><input class="easyui-textbox "  name="text[]"   type="text"    value="" ></td>

         	 <td>字段显示长度1</td>
			 <td><input class="easyui-textbox "  name="length[]"   type="text"    value="" ></td>
			<td><a href="javascript:void(0)" onclick="mydel(1)"><img  src="\assets\images\ico\verify_error.png"></a></td>
         	</tr>



         	<?php }else{   $i=1; foreach($field  as $row) { ?>
         		   	<tr id="tr<?php echo $i ?>">
					<td>采集字段名<?php echo $i;?></td>
						<td align="left" width="200">
							 <input  id="myid"  type="hidden"  value="1">
							 <input class="easyui-textbox "  name="name[]"   type="text"    value="<?php echo $row['name'] ?>" >
		             	</td>
		             <td>字段显示名称<?php echo $i;?></td>
						<td><input class="easyui-textbox "  name="text[]"   type="text"    value="<?php echo $row['text'] ?>" ></td>

		         	 <td>字段显示长度<?php echo $i;?></td>
					<td><input class="easyui-textbox "  name="length[]"   type="text"    value="<?php echo $row['length'] ?>" ></td>
					<td><a href="javascript:void(0)" onclick="mydel(<?php echo $i;?>)"><img  src="\assets\images\ico\verify_error.png"></a></td>
		         	</tr>
         	<?php  $i++;}}  ?>
		</table>
			<a href="javascript:void(0)" class="easyui-linkbutton c9" style="width:80%" onclick="submitForm()">提            交</a>
   </form>

<script type="text/javascript">

	function myadd(){

       	var  id=  parseInt($("#myid").attr("value"))+1;
     	var targetObj = $("<tr id='tr"+id+"'><td>采集字段名"+id+"</td><td><input name='name[]' class='easyui-textbox'></td><td>字段显示名称"+id+"</td><td><input name='text[]'  class='easyui-textbox'></td><td>字段显示长度"+id+"</td><td><input name='length[]'  class='easyui-textbox'></td><td><a href='javascript:void(0)' onclick='mydel("+id+")'><img  src='/assets/images/ico/verify_error.png'></a></td></tr>").appendTo("#mytable");
     	$.parser.parse(targetObj);
     	$("#myid").attr("value",id);

	}

	function mydel(id){
		$("#tr"+id).remove();
	}
	function submitForm(){

       					$('#form1').form('submit',{
							onSubmit:function(){

										var url = "<?php echo $action_url ?>";
									     $.ajax({
											   type: "POST",
											   url:url,
											   dataType:"text",
											   data:$("#form1").serialize(),
											   success: function(msg){
													alert(msg);
											   }
										});
							}
					 	});


		}


</script>

</body>
</html>